<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="com.mytrip.model.Trip" import="java.util.*" import="java.text.SimpleDateFormat" import="com.mytrip.model.Userinfo" import="com.mytrip.webapp.filter.CtxSessionBag"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>出发吧</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<jsp:include page="/common/include_js.jsp" />
<link rel="stylesheet" type="text/css" media="screen" href="<%=request.getContextPath() %>/front/css/css.css" />
</head>
<body>
<div id="wrap">
  <jsp:include page="include/top.jsp">
  	<jsp:param name="t" value="1" />
  </jsp:include>
<%
      		Userinfo userinfo = (Userinfo)CtxSessionBag.getSessionBag().getUserinfo();
      	%>
  <div id="main">
    <div id="main_left">
      <div id="md_01">
        <div class="user_box"><a href=""><img src="<%=request.getContextPath() %>/front/images/plofile.gif" /></a></div>
        <div class="user_info"> <span class="welcome">欢迎回来，</span> <span  class="welcome"><a href="<%=request.getContextPath() %>/front/myDetail.action" class="name"><%=userinfo.getRealName()%></a></span>
          <p>您现在所在的城市，<span class="ct">上海</span>。 您已经有 <span class="welcome">${tripCityCnt}</span> 个旅行城市</p>
        </div>
      </div>
      
      <jsp:include page="include/tripStep.jsp" />
       <div class="start_trip"><a href="<%=request.getContextPath() %>/front/trip!goAdd.action" class="start_btn">开始我的新旅行</a></div>
      <div class="GTbox">
        <div class="GTtitle">
          <h2>最新行程</h2>
          <div class="TR"><a href="<%=request.getContextPath() %>/front/trip!showNextTrip.action">更多&gt;&gt;</a></div>
        </div>
        <div class="content">
          <table width="100%" border="0" cellspacing="0" cellpadding="0">
        <%
        	SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        
        	List<Trip> tripList = (List<Trip>)request.getAttribute("tripList");
        	for(Trip trip : tripList){
        		Date startDate = trip.getStartDate();
        		Date endDate = trip.getEndDate();
        		long a = (endDate.getTime()-startDate.getTime())/(1000*60*60*24)+1;
        %>
        	<tr>
              <td><img src="<%=request.getContextPath() %><%=trip.getPhoto()%>" width="31" height="29" /></td>
              <td><div style="min-height:35px"> <a href="javascript:void(0);" onclick="window.location.href='<%=request.getContextPath() %>/front/trip!detail.action?id=<%=trip.getId()%>';"><%=trip.getName()%></a>&nbsp;(<%=a%> 天) <span style="color:red;"><%if(!"1".equals(trip.getIsPublic())){out.print("私有行程");}%></span><br>
                  <span class="fntXS curPtr"><%=trip.getFromCityStr()%> ~ <%=trip.getToCityStr()%></span>
                  <div> <span>通知成员数</span>: <%=trip.getNotifyUserList().size()%> </div>
                </div></td>
              <td><div style="white-space: nowrap;"><%=sdf.format(startDate)%> ~ <%=sdf.format(endDate)%></div></td>
              <td><a href="javascript:void(0);" onclick="window.location.href='<%=request.getContextPath() %>/front/trip!detail.action?id=<%=trip.getId()%>';">查看</a>&nbsp;<a href="javascript:void(0);" onclick="if(confirm('确认删除该行程?')){window.location.href='<%=request.getContextPath() %>/front/trip!delete.action?id=<%=trip.getId()%>&t=1'}">删除</a></td>
            </tr>
            <tr>
              <td  colspan="4"><div class="dot"></div></td>
            </tr>
        <%
        	}
        %>
          </table>
        </div>
      </div>
      <div class="GTbox">
        <div class="GTtitle">
          <h3>我关注的人</h3>
          <div class="TR"><a href="">更多&gt;&gt;</a></div>
        </div>
        <div class="content">
          <ul class="box_list">
            <li><a href="" class="ui_avatar"><img src="<%=request.getContextPath() %>/front/images/plofile.gif" /></a><a href="" class="textoverflow">小豆妈</a></li>
            <li><a href="" class="ui_avatar"><img src="<%=request.getContextPath() %>/front/images/pp.jpg" /></a><a href="" class="textoverflow">可可在线</a></li>
            <li><a href="" class="ui_avatar"><img src="<%=request.getContextPath() %>/front/images/p2.gif" /></a><a href="" class="textoverflow">plyer</a></li>
            <li><a href="" class="ui_avatar"><img src="<%=request.getContextPath() %>/front/images/p3.gif" /></a><a href="" class="textoverflow">小豆爱妈妈</a></li>
            <li><a href="" class="ui_avatar"><img src="<%=request.getContextPath() %>/front/images/p4.gif" /></a><a href="" class="textoverflow">小豆爱妈妈</a></li>
            <li><a href="" class="ui_avatar"><img src="<%=request.getContextPath() %>/front/images/p5.gif" /></a><a href="" class="textoverflow">小豆爱妈妈</a></li>
            <li><a href="" class="ui_avatar"><img src="<%=request.getContextPath() %>/front/images/p3.gif" /></a><a href="" class="textoverflow">小豆爱妈妈</a></li>
            <li><a href="" class="ui_avatar"><img src="<%=request.getContextPath() %>/front/images/p2.gif" /></a><a href="" class="textoverflow">小豆爱妈妈</a></li>
            <li><a href="" class="ui_avatar"><img src="<%=request.getContextPath() %>/front/images/p5.gif" /></a><a href="" class="textoverflow">小豆爱妈妈</a></li>
          </ul>
        </div>
      </div>
      <div class="GTbox">
        <div class="GTtitle">
          <h3>行程统计</h3>
        </div>
        <div class="content">
          <div class="fLt fwth">
            <div class="secHdr"> <span> 1ST PLACE FOR DISTANCE TRAVELED </span>
              <div class="clr"></div>
            </div>
            <div class="stdHPad">
              <div class="user_box"><a href=""><img src="<%=request.getContextPath() %>/front/images/plofile.gif" /></a></div>
              <span class="fLt"> 1. <a href="<%=request.getContextPath() %>/front/myDetail.action" class="name"><%=userinfo.getRealName()%></a> </span> <span class="fRt"> 0 km </span>
              <div class="clr"></div>
            </div>
          </div>
          <div class="fRt fwth">
            <div class="secHdr"> <span class="lbl"> 全程统计 </span>
              <div class="clr"></div>
            </div>
            
		<%
          	Map<String,String> statisticsYear = (Map<String,String>)request.getAttribute("statisticsYear");
          	Map<String,String> statisticsTotal = (Map<String,String>)request.getAttribute("statisticsTotal");
		%>
            
            <table cellspacing="0" id="stats_tb" >
              <tbody>
                <tr>
                  <th>&nbsp;</th>
                  <th align="right">${currentYearStr}</th>
                  <th align="right">总计</th>
                </tr>
                <tr>
                  <td class="tdBgGry">行程</td>
                  <td class="tdBgGry" align="right"><%=statisticsYear.get("tripCntYear")%></td>
                  <td class="tdBgGry" align="right"><%=statisticsTotal.get("tripCntTotal")%></td>
                </tr>
                <tr>
                  <td>天数</td>
                  <td align="right"><%=statisticsYear.get("tripDateCntYear")%></td>
                  <td align="right"><%=statisticsTotal.get("tripDateCntTotal")%></td>
                </tr>
                <tr>
                  <td class="tdBgGry">距离</td>
                  <td class="tdBgGry" align="right">0 km</td>
                  <td class="tdBgGry" align="right">0 km</td>
                </tr>
                <tr>
                  <td>城市</td>
                  <td align="right"><%=statisticsYear.get("tripCityCntYear")%></td>
                  <td align="right"><%=statisticsTotal.get("tripCityCntTotal")%></td>
                </tr>
              </tbody>
            </table>
          </div>
          <div class="clr"></div>
        </div>
      </div>
    </div>
    
    <jsp:include page="include/main-right.jsp" />
  </div>
  
  <jsp:include page="include/bottom.jsp" />
</div>
</body>
</html>